﻿using Coldairarrow.Business.AM;
using Coldairarrow.Entity.AM;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.AM
{
    [Route("/AM/[controller]/[action]")]
    public class am_assetitemController : BaseApiController
    {
        #region DI

        public am_assetitemController(Iam_assetitemBusiness am_assetitemBus)
        {
            _am_assetitemBus = am_assetitemBus;
        }

        Iam_assetitemBusiness _am_assetitemBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<AM_AssetItem>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _am_assetitemBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<AM_AssetItem> GetTheData(IdInputDTO input)
        {
            return await _am_assetitemBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(AM_AssetItem data)
        {
            if (data.ID.IsNullOrEmpty())
            {
                InitEntity(data);

                await _am_assetitemBus.AddDataAsync(data);
            }
            else
            {
                await _am_assetitemBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _am_assetitemBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}